package com.vben.common.exception.enums;

import lombok.Getter;

/**
 * 错误码枚举
 *
 * @author sunnfun
 */
@Getter
public enum ErrorCode {
    // 通用错误码
    SUCCESS(200, "操作成功"),
    INTERNAL_ERROR(500, "系统内部错误"),
    PARAM_INVALID(400, 1001, "参数不合法"),
    RESOURCE_NOT_FOUND(400, 1002, "访问资源不存在"),
    NOT_ROLE(403, 1003, "没有操作权限，请联系管理员"),

    // auth模块相关错误吗 (2000-2999)
    NOT_LOGIN(401, 2001, "未登陆"),
    USER_NOT_FOUND(401, 2002, "用户不存在"),
    PASSWORD_MISMATCH(401, 2003, "密码错误"),
    ACCOUNT_LOCKED(403, 2004, "账户已锁定"),
    ACCOUNT_DISABLED(403, 2005, "账户已被禁用"),
    TOO_MANY_ATTEMPTS(429, 2006, "操作过于频繁");


    private final int httpStatus;
    private final int code;
    private final String message;

    // 构造函数重载（兼容没有业务码的情况）
    ErrorCode(int httpStatus, int code, String message) {
        this.httpStatus = httpStatus;
        this.code = code;
        this.message = message;
    }

    ErrorCode(int code, String message) {
        this.httpStatus = 400;
        this.code = code;
        this.message = message;
    }
}